using System;
using CommunityToolkit.Mvvm.ComponentModel;
using AvaloniaUiKit.SampleApp.ViewModels.Pages;
using CommunityToolkit.Mvvm.DependencyInjection;

namespace AvaloniaUiKit.SampleApp.Services
{
    public partial class NavigationService : ObservableObject, INavigationService
    {
        [ObservableProperty]
        private IPageViewModel _currentPage;
        
        public NavigationService()
        {
            _currentPage = new HomePageViewModel();
        }

        public void Navigate(string pageName)
        {
            CurrentPage = pageName switch
            {
                "Home" => new HomePageViewModel(),
                "Buttons" => new ButtonsPageViewModel(),
                "Cards" => new CardsPageViewModel(),
                "Grids" => new GridsPageViewModel(),
                "Panels" => new PanelsPageViewModel(),
                "FlexWrapPanel" => new FlexWrapPanelPageViewModel(),
                "Text Fields" => new TextFieldsPageViewModel(),
                "Selection" => new SelectionPageViewModel(),
                "Notifications" => new NotificationsPageViewModel(),
                "MvvmDialogs" => Ioc.Default.GetService<MvvmDialogsPageViewModel>()!,
                _ => throw new ArgumentException($"未知页面名称: {pageName}", nameof(pageName))
            };
        }

        public void NavigateToHome()
        {
            CurrentPage = new HomePageViewModel();
        }
    }
}